package com.cloudeye.im.easemob;

import com.easemob.im.server.EMProperties;
import com.easemob.im.server.EMService;
import com.easemob.im.server.api.Context;
import com.easemob.im.server.api.DefaultContext;
import com.easemob.im.server.api.attachment.AttachmentApi;
import com.easemob.im.server.api.block.BlockApi;
import com.easemob.im.server.api.contact.ContactApi;
import com.easemob.im.server.api.group.GroupApi;
import com.easemob.im.server.api.message.MessageApi;
import com.easemob.im.server.api.metadata.MetadataApi;
import com.easemob.im.server.api.room.RoomApi;
import com.easemob.im.server.api.user.UserApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: lafangyuan
 * @Date: 2021/11/1 11:15
 */
public class EaseMobService extends EMService {

    protected static final Logger log = LoggerFactory.getLogger(EMService.class);
    protected final Context context;
    protected final BlockApi blockV1;
    protected final ContactApi contactApi;
    protected final AttachmentApi attachmentApi;
    protected final GroupApi groupApi;
    protected final MessageApi messageApi;
    protected final RoomApi roomApi;
    protected final UserApi userApi;
    protected final MetadataApi metadataApi;

    public EaseMobService(EMProperties properties) {
        super(properties);
        log.debug("EMService properties: {}", properties);
        this.context = new DefaultContext(properties);
        this.blockV1 = new BlockApi(this.context);
        this.contactApi = new ContactApi(this.context);
        this.attachmentApi = new AttachmentApi(this.context);
        this.messageApi = new MessageApi(this.context);
        this.groupApi = new EaseMobGroupApi(this.context);
        this.roomApi = new RoomApi(this.context);
        this.userApi = new EaseMobUserApi(this.context);
        this.metadataApi = new MetadataApi(this.context);
    }


    public BlockApi block() {
        return this.blockV1;
    }

        public ContactApi contact() {
        return this.contactApi;
    }

        public AttachmentApi attachment() {
        return this.attachmentApi;
    }

        public GroupApi group() {
        return this.groupApi;
    }

        public MessageApi message() {
        return this.messageApi;
    }

        public UserApi user() {
        return this.userApi;
    }

        public RoomApi room() {
        return this.roomApi;
    }

        public MetadataApi metadata() {
        return this.metadataApi;
    }
}
